package net.oschina.aibinxiao.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: AiBinXiao
 * @Description: SimpleTrigger
 * @Date: 2017/10/12 8:35
 */

public class HelloJob5 implements Job{

    public void execute(JobExecutionContext context) throws JobExecutionException{
        // 打印当前时间，格式为 yyyy-MM-dd HH:mm:ss
        try {
            Thread.sleep(5000L); // 让job执行时间超过2秒，检验shutdown(true)是否会等job执行完再关闭
        } catch (InterruptedException e){
            e.printStackTrace();
        }
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String dateStr = sdf.format(date);
        System.out.println("当前时间是：" + dateStr);
        System.out.println("Hello world !");

    }
}
